/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ssi.mrms.service.Impl;

import com.ssi.mrms.dao.ComplaintDao;
import com.ssi.mrms.model.DataTableModel;
import com.ssi.mrms.model.RMcphdrModel;
import com.ssi.mrms.service.ComplaintService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author jirapatjantsakool
 */
@Service("ComplaintService")
public class ComplaintServiceImpl implements ComplaintService {
    
    @Autowired ComplaintDao dao;

    @Override
    public List<RMcphdrModel> getAllComplaint() {
        return dao.findAll();
    }

    @Override
    public RMcphdrModel getComplaintById(Integer cphid) {
        return dao.findById(cphid);
    }

    @Override
    @Transactional
    public void save(RMcphdrModel model) throws Exception {
        dao.create(model);
    }

    @Override
    @Transactional
    public boolean update(RMcphdrModel model) {
        return dao.update(model);
    }

    @Override
    @Transactional
    public boolean delete(RMcphdrModel model) {
        return dao.delete(model);
    }

    @Override
    public DataTableModel<RMcphdrModel> getComplaintDataTable(RMcphdrModel model, int iDisplayStart, int iDisplayLength) {
        return dao.findDataTable(model, iDisplayStart, iDisplayLength);
    }
    
}
